<!DOCTYPE html>
<body>
<script src="../../../resources/js-test.js"></script>
<input id="timeInput" type="time" value="01:01" style="font-size:20px">
<script>
function shadowPseudoIdOfFocused() {
    return internals.shadowPseudoId(internals.shadowRoot(timeInput).activeElement);
}

description('Check if focus() for focused input does not change focused sub-field.');

debug('Move focus to the second sub-field:');
var timeInput = document.getElementById('timeInput');
timeInput.focus();
shouldBe('document.activeElement', 'timeInput');
eventSender.keyDown('ArrowRight');
shouldBeEqualToString('shadowPseudoIdOfFocused(timeInput)', '-webkit-datetime-edit-minute-field');
shouldBeEqualToString('timeInput.focus(); shadowPseudoIdOfFocused(timeInput)', '-webkit-datetime-edit-minute-field');

debug('Click on a delimiter between sub-fields, then check if focused element is not changed:');
var focusedField = internals.shadowRoot(timeInput).activeElement;
eventSender.mouseMoveTo(focusedField.offsetLeft + focusedField.offsetWidth + 10, focusedField.offsetTop + 10);
eventSender.mouseDown();
eventSender.mouseUp();
shouldBeEqualToString('shadowPseudoIdOfFocused(timeInput)', '-webkit-datetime-edit-minute-field');
</script>
</body>
